home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00022_DitchClass.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  6.0 KB  |  238 lines

  1. property state, bucketFull, bucketChan, emptyBucket, dirtLoads, centerVertList, rightVertList, horizList, firstArrowChan, buttonData, patchChan, firstPatch, dirtChan, sandboxChan
  2. global gTruckObject, gSimObject, gLevelObject
  3.  
  4. on birth me
  5.   set state to 1
  6.   set bucketFull to 0
  7.   set dirtLoads to 0
  8.   set patchChan to 4
  9.   set bucketChan to 5
  10.   set dirtChan to 6
  11.   set firstArrowChan to 7
  12.   set sandboxChan to 27
  13.   set centerVertList to [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]
  14.   set rightVertList to [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1]
  15.   set horizList to [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1]
  16.   set buttonData to [1: [0, 1, 1, 1], 2: [0, 1, 0, 0], 3: [1, 0, 0, 0], 4: [0, 0, 1, 1], 5: [1, 0, 0, 0]]
  17.   return me
  18. end
  19.  
  20. on setup me
  21.   add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gDitchObject, me )", 27, 27, 5, "RCA-07VO01", "RCA-07RO01"))
  22.   add(gActorList, birth(script "Rollover Anim Button Class", "help( gDitchObject, me )", 28, 28, 11, EMPTY, "RCA-05RO02"))
  23.   puppetSprite(bucketChan, 1)
  24.   puppetSprite(patchChan, 1)
  25.   puppetSprite(dirtChan, 1)
  26.   set the visible of sprite firstArrowChan to 0
  27.   set emptyBucket to the castNum of sprite bucketChan
  28.   set firstPatch to the castNum of sprite patchChan
  29. end
  30.  
  31. on upButton me
  32.   if state = 3 then
  33.     buttonSound(me)
  34.     repeat with delta in centerVertList
  35.       moveVert(me, -1 * delta)
  36.     end repeat
  37.     set state to 1
  38.   else
  39.     if state = 5 then
  40.       buttonSound(me)
  41.       repeat with delta in rightVertList
  42.         moveVert(me, -1 * delta)
  43.       end repeat
  44.       set state to 4
  45.     end if
  46.   end if
  47.   updateButtons(me)
  48. end
  49.  
  50. on downButton me
  51.   if state = 1 then
  52.     buttonSound(me)
  53.     repeat with delta in centerVertList
  54.       moveVert(me, delta)
  55.     end repeat
  56.     if bucketFull then
  57.       depositDirt(me)
  58.     end if
  59.     set state to 3
  60.     updateButtons(me)
  61.   else
  62.     if state = 4 then
  63.       buttonSound(me)
  64.       repeat with delta in rightVertList
  65.         moveVert(me, delta)
  66.       end repeat
  67.       fillBucket(me)
  68.       set state to 5
  69.       go(the frame)
  70.       updateButtons(me)
  71.     end if
  72.   end if
  73. end
  74.  
  75. on depositDirt me
  76.   set dirtLoads to dirtLoads + 1
  77.   set the castNum of sprite patchChan to firstPatch + dirtLoads - 1
  78.   set the locH of sprite patchChan to 320
  79.   puppetSound("1030dump")
  80.   emptyBucket(me)
  81.   puppetTransition(51, 1)
  82.   go(the frame)
  83.   if dirtLoads = 3 then
  84.     finishedGame(me)
  85.   end if
  86. end
  87.  
  88. on finishedGame me
  89.   startTimer()
  90.   repeat while the timer < 30
  91.   end repeat
  92.   puppetSound(0)
  93.   puppetSound("1030cheer")
  94.   set the castNum of sprite patchChan to firstPatch + dirtLoads
  95.   puppetTransition(51, 1)
  96.   go(the frame)
  97.   set state to 1
  98.   set bucketFull to 0
  99.   set dirtLoads to 0
  100.   repeat with button = 1 to 4
  101.     set the visible of sprite (firstArrowChan + button - 1) to 1
  102.   end repeat
  103.   set the tileNum of the blockedCellObj of gTruckObject to 0
  104.   set the tileType of the blockedCellObj of gTruckObject to #BG
  105.   set x to blockCrossings(the cell of gTruckObject, getLast(the recordedMoveList of gSimObject))
  106.   finishSound(me)
  107.   clearAllActors()
  108.   puppetSprite(bucketChan, 0)
  109.   puppetSprite(patchChan, 0)
  110.   puppetSprite(dirtChan, 0)
  111.   keepSandboxBut(sandboxChan)
  112.   puppetPalette("DitchPal")
  113.   go("Grass")
  114.   go(the frame + 1)
  115.   puppetSprite(48, 0)
  116.   puppetPalette("SimPal", 60)
  117.   updateStage()
  118.   puppetPalette(0)
  119.   predrawSimButtons(gSimObject)
  120.   go(label("Simulator" & string(the level of gLevelObject)))
  121.   abort()
  122. end
  123.  
  124. on fillBucket me
  125.   set bucketFull to 1
  126.   set the castNum of sprite bucketChan to emptyBucket + 1
  127.   if dirtLoads = 2 then
  128.     set the locH of sprite dirtChan to 1000
  129.   end if
  130.   puppetTransition(51, 1)
  131. end
  132.  
  133. on emptyBucket me
  134.   set bucketFull to 0
  135.   set the castNum of sprite bucketChan to emptyBucket
  136. end
  137.  
  138. on rightButton me
  139.   if state = 2 then
  140.     buttonSound(me)
  141.     repeat with delta in horizList
  142.       moveHoriz(me, delta)
  143.     end repeat
  144.     set state to 1
  145.   else
  146.     if state = 1 then
  147.       buttonSound(me)
  148.       repeat with delta in horizList
  149.         moveHoriz(me, delta)
  150.       end repeat
  151.       set state to 4
  152.     end if
  153.   end if
  154.   updateButtons(me)
  155. end
  156.  
  157. on leftButton me
  158.   if state = 1 then
  159.     buttonSound(me)
  160.     repeat with delta in horizList
  161.       moveHoriz(me, -1 * delta)
  162.     end repeat
  163.     set state to 2
  164.   else
  165.     if state = 4 then
  166.       buttonSound(me)
  167.       repeat with delta in horizList
  168.         moveHoriz(me, -1 * delta)
  169.       end repeat
  170.       set state to 1
  171.     end if
  172.   end if
  173.   updateButtons(me)
  174. end
  175.  
  176. on buttonSound me
  177.   puppetSound("arrowClick")
  178.   updateStage()
  179.   finishSound(me)
  180.   puppetSound("1030machine")
  181. end
  182.  
  183. on moveVert me, delta
  184.   startTimer()
  185.   set the locV of sprite bucketChan to the locV of sprite bucketChan + delta
  186.   moveSprites(me)
  187. end
  188.  
  189. on moveHoriz me, delta
  190.   startTimer()
  191.   set the locH of sprite bucketChan to the locH of sprite bucketChan + delta
  192.   moveSprites(me)
  193. end
  194.  
  195. on finishSound me
  196.   repeat while soundBusy(1)
  197.   end repeat
  198.   puppetSound(0)
  199. end
  200.  
  201. on updateButtons me
  202.   set buttonList to getProp(buttonData, state)
  203.   repeat with button = 1 to count(buttonList)
  204.     set boolean to getAt(buttonList, button)
  205.     set the visible of sprite (firstArrowChan + button - 1) to boolean
  206.   end repeat
  207.   finishSound(me)
  208. end
  209.  
  210. on moveSprites me
  211.   repeat while the timer < 2
  212.   end repeat
  213.   updateStage()
  214. end
  215.  
  216. on goMenu me, buttonObject
  217.   forgetObstacle(gSimObject)
  218.   set state to 1
  219.   set bucketFull to 0
  220.   set dirtLoads to 0
  221.   clearAllActors()
  222.   unpuppetAll()
  223.   makeButtonJump(buttonObject)
  224.   puppetSprite(48, 0)
  225.   puppetPalette("DitchPal")
  226.   go("Grass")
  227.   go(the frame + 1)
  228.   repeat with button = 1 to 4
  229.     set the visible of sprite (firstArrowChan + button - 1) to 1
  230.   end repeat
  231.   unLoadCast()
  232.   goLocationMap()
  233. end
  234.  
  235. on help me, buttonObject
  236.   birth(script "Help Parent", buttonObject, #Ditch)
  237. end
  238.